﻿package net.wangit.adm.role;

import java.util.HashMap;
import java.util.Map;

import net.wangit.user.role.Role;
import net.wangit.user.role.RoleFactory;
import net.wangit.util.Checker;


public class RolePrivilegeTreeFactory extends PrivilegeTreeFactory {

	public RolePrivilegeTreeFactory() {
	}

	protected String getDomain() {
		return RolePrivilegeUI.getAndSetDomain();
	}

	protected Map getPrivileges() throws Exception {
		String roleId = RolePrivilegeUI.getAndSetRoleId();
		if (Checker.isEmpty(roleId)) {
			return new HashMap();
		} else {
			Role role = RoleFactory.getRole(roleId);
			return ((Map) (role != null ? role.getPrivileges() : new HashMap()));
		}
	}

	protected boolean isDisabled() {
		return false;
	}
}
